﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using FileSystem.Services.IServices;
using FileSystem.Services.Realization;
using Moq;

namespace FileSystem.UnitTest.Helpers {
    /// <summary>
    /// 访问控制信息存储帮助类
    /// </summary>
    public class AccessControlInfoStorageHelper {
        /// <summary>
        /// 获得已初始化的访问控制信息存储
        /// </summary>
        public static async Task<AccessControlInfoStorage>
            GetInitializedAccessControlInfoStorageAsync() {
            var accessControlInfoStorage = new AccessControlInfoStorage(
                new Mock<IPreferenceStorage>().Object);
            await accessControlInfoStorage.InitializeAsync();
            return accessControlInfoStorage;
        }

        /// <summary>
        /// 删除访问控制信息数据库文件
        /// </summary>
        public static async Task RemoveDatabaseFile() {
            var accessControlInfoStorage = new AccessControlInfoStorage(null);
            await accessControlInfoStorage.CloseAsync();
            File.Delete(AccessControlInfoStorage.DbPath);
        }
    }
}